{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script><script type=\"text/javascript\">if (window.MathJax) {MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script><script>requirejs.config({paths: { 'plotly': ['https://cdn.plot.ly/plotly-latest.min']},});if(!window._Plotly) {require(['plotly'],function(plotly) {window._Plotly=plotly;});}</script>"
      ],
      "text/vnd.plotly.v1+html": [
       "<script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script><script type=\"text/javascript\">if (window.MathJax) {MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script><script>requirejs.config({paths: { 'plotly': ['https://cdn.plot.ly/plotly-latest.min']},});if(!window._Plotly) {require(['plotly'],function(plotly) {window._Plotly=plotly;});}</script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import plotly\n",
    "import plotly.figure_factory as ff\n",
    "plotly.offline.init_notebook_mode(connected=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Simple Gantt Chart"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.plotly.v1+json": {
       "config": {
        "linkText": "Export to plot.ly",
        "plotlyServerURL": "https://plot.ly",
        "showLink": true
       },
       "data": [
        {
         "marker": {
          "color": "white"
         },
         "name": "",
         "type": "scatter",
         "uid": "fa39a247-17ca-4752-ab3e-891f891e3278",
         "x": [
          "2009-01-01",
          "2009-02-28"
         ],
         "y": [
          0,
          0
         ]
        },
        {
         "marker": {
          "color": "white"
         },
         "name": "",
         "type": "scatter",
         "uid": "a9e42ccc-0625-434d-8d14-ed0e51cf4361",
         "x": [
          "2009-03-05",
          "2009-04-15"
         ],
         "y": [
          1,
          1
         ]
        },
        {
         "marker": {
          "color": "white"
         },
         "name": "",
         "type": "scatter",
         "uid": "fd643c52-8f30-4328-86ca-16f296dea049",
         "x": [
          "2009-02-20",
          "2009-05-30"
         ],
         "y": [
          2,
          2
         ]
        }
       ],
       "layout": {
        "height": 600,
        "hovermode": "closest",
        "shapes": [
         {
          "fillcolor": "rgb(31, 119, 180)",
          "line": {
           "width": 0
          },
          "opacity": 1,
          "type": "rect",
          "x0": "2009-01-01",
          "x1": "2009-02-28",
          "xref": "x",
          "y0": -0.2,
          "y1": 0.2,
          "yref": "y"
         },
         {
          "fillcolor": "rgb(255, 127, 14)",
          "line": {
           "width": 0
          },
          "opacity": 1,
          "type": "rect",
          "x0": "2009-03-05",
          "x1": "2009-04-15",
          "xref": "x",
          "y0": 0.8,
          "y1": 1.2,
          "yref": "y"
         },
         {
          "fillcolor": "rgb(44, 160, 44)",
          "line": {
           "width": 0
          },
          "opacity": 1,
          "type": "rect",
          "x0": "2009-02-20",
          "x1": "2009-05-30",
          "xref": "x",
          "y0": 1.8,
          "y1": 2.2,
          "yref": "y"
         }
        ],
        "showlegend": false,
        "title": "Gantt Chart",
        "width": 900,
        "xaxis": {
         "rangeselector": {
          "buttons": [
           {
            "count": 7,
            "label": "1w",
            "step": "day",
            "stepmode": "backward"
           },
           {
            "count": 1,
            "label": "1m",
            "step": "month",
            "stepmode": "backward"
           },
           {
            "count": 6,
            "label": "6m",
            "step": "month",
            "stepmode": "backward"
           },
           {
            "count": 1,
            "label": "YTD",
            "step": "year",
            "stepmode": "todate"
           },
           {
            "count": 1,
            "label": "1y",
            "step": "year",
            "stepmode": "backward"
           },
           {
            "step": "all"
           }
          ]
         },
         "showgrid": false,
         "type": "date",
         "zeroline": false
        },
        "yaxis": {
         "autorange": false,
         "range": [
          -1,
          4
         ],
         "showgrid": false,
         "ticktext": [
          "Job A",
          "Job B",
          "Job C"
         ],
         "tickvals": [
          0,
          1,
          2
         ],
         "zeroline": false
        }
       }
      },
      "text/html": [
       "<div id=\"7c0311c8-98d0-434c-a5b8-a437c68ca7c5\" style=\"height: 600px; width: 900px;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"7c0311c8-98d0-434c-a5b8-a437c68ca7c5\", [{\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"x\": [\"2009-01-01\", \"2009-02-28\"], \"y\": [0, 0], \"type\": \"scatter\", \"uid\": \"fa39a247-17ca-4752-ab3e-891f891e3278\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"x\": [\"2009-03-05\", \"2009-04-15\"], \"y\": [1, 1], \"type\": \"scatter\", \"uid\": \"a9e42ccc-0625-434d-8d14-ed0e51cf4361\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"x\": [\"2009-02-20\", \"2009-05-30\"], \"y\": [2, 2], \"type\": \"scatter\", \"uid\": \"fd643c52-8f30-4328-86ca-16f296dea049\"}], {\"height\": 600, \"hovermode\": \"closest\", \"shapes\": [{\"fillcolor\": \"rgb(31, 119, 180)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2009-01-01\", \"x1\": \"2009-02-28\", \"xref\": \"x\", \"y0\": -0.2, \"y1\": 0.2, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(255, 127, 14)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2009-03-05\", \"x1\": \"2009-04-15\", \"xref\": \"x\", \"y0\": 0.8, \"y1\": 1.2, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(44, 160, 44)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2009-02-20\", \"x1\": \"2009-05-30\", \"xref\": \"x\", \"y0\": 1.8, \"y1\": 2.2, \"yref\": \"y\"}], \"showlegend\": false, \"title\": \"Gantt Chart\", \"width\": 900, \"xaxis\": {\"rangeselector\": {\"buttons\": [{\"count\": 7, \"label\": \"1w\", \"step\": \"day\", \"stepmode\": \"backward\"}, {\"count\": 1, \"label\": \"1m\", \"step\": \"month\", \"stepmode\": \"backward\"}, {\"count\": 6, \"label\": \"6m\", \"step\": \"month\", \"stepmode\": \"backward\"}, {\"count\": 1, \"label\": \"YTD\", \"step\": \"year\", \"stepmode\": \"todate\"}, {\"count\": 1, \"label\": \"1y\", \"step\": \"year\", \"stepmode\": \"backward\"}, {\"step\": \"all\"}]}, \"showgrid\": false, \"type\": \"date\", \"zeroline\": false}, \"yaxis\": {\"autorange\": false, \"range\": [-1, 4], \"showgrid\": false, \"ticktext\": [\"Job A\", \"Job B\", \"Job C\"], \"tickvals\": [0, 1, 2], \"zeroline\": false}}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script>"
      ],
      "text/vnd.plotly.v1+html": [
       "<div id=\"7c0311c8-98d0-434c-a5b8-a437c68ca7c5\" style=\"height: 600px; width: 900px;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"7c0311c8-98d0-434c-a5b8-a437c68ca7c5\", [{\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"x\": [\"2009-01-01\", \"2009-02-28\"], \"y\": [0, 0], \"type\": \"scatter\", \"uid\": \"fa39a247-17ca-4752-ab3e-891f891e3278\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"x\": [\"2009-03-05\", \"2009-04-15\"], \"y\": [1, 1], \"type\": \"scatter\", \"uid\": \"a9e42ccc-0625-434d-8d14-ed0e51cf4361\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"x\": [\"2009-02-20\", \"2009-05-30\"], \"y\": [2, 2], \"type\": \"scatter\", \"uid\": \"fd643c52-8f30-4328-86ca-16f296dea049\"}], {\"height\": 600, \"hovermode\": \"closest\", \"shapes\": [{\"fillcolor\": \"rgb(31, 119, 180)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2009-01-01\", \"x1\": \"2009-02-28\", \"xref\": \"x\", \"y0\": -0.2, \"y1\": 0.2, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(255, 127, 14)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2009-03-05\", \"x1\": \"2009-04-15\", \"xref\": \"x\", \"y0\": 0.8, \"y1\": 1.2, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(44, 160, 44)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2009-02-20\", \"x1\": \"2009-05-30\", \"xref\": \"x\", \"y0\": 1.8, \"y1\": 2.2, \"yref\": \"y\"}], \"showlegend\": false, \"title\": \"Gantt Chart\", \"width\": 900, \"xaxis\": {\"rangeselector\": {\"buttons\": [{\"count\": 7, \"label\": \"1w\", \"step\": \"day\", \"stepmode\": \"backward\"}, {\"count\": 1, \"label\": \"1m\", \"step\": \"month\", \"stepmode\": \"backward\"}, {\"count\": 6, \"label\": \"6m\", \"step\": \"month\", \"stepmode\": \"backward\"}, {\"count\": 1, \"label\": \"YTD\", \"step\": \"year\", \"stepmode\": \"todate\"}, {\"count\": 1, \"label\": \"1y\", \"step\": \"year\", \"stepmode\": \"backward\"}, {\"step\": \"all\"}]}, \"showgrid\": false, \"type\": \"date\", \"zeroline\": false}, \"yaxis\": {\"autorange\": false, \"range\": [-1, 4], \"showgrid\": false, \"ticktext\": [\"Job A\", \"Job B\", \"Job C\"], \"tickvals\": [0, 1, 2], \"zeroline\": false}}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "df = [\n",
    "    dict(Task=\"Job A\", Start='2009-01-01', Finish='2009-02-28'),\n",
    "    dict(Task=\"Job B\", Start='2009-03-05', Finish='2009-04-15'),\n",
    "    dict(Task=\"Job C\", Start='2009-02-20', Finish='2009-05-30')\n",
    "]\n",
    "fig = ff.create_gantt(df)\n",
    "plotly.offline.iplot(fig, filename='gantt-simple-gantt-chart')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Index by xxxx Variable"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.plotly.v1+json": {
       "config": {
        "linkText": "Export to plot.ly",
        "plotlyServerURL": "https://plot.ly",
        "showLink": true
       },
       "data": [
        {
         "marker": {
          "color": "white"
         },
         "name": "",
         "showlegend": false,
         "type": "scatter",
         "uid": "10b5c508-b369-4e48-a08c-429b9e347a71",
         "x": [
          "2009-01-01",
          "2009-02-28"
         ],
         "y": [
          0,
          0
         ]
        },
        {
         "marker": {
          "color": "white"
         },
         "name": "",
         "showlegend": false,
         "type": "scatter",
         "uid": "d724e365-fa06-417e-bd91-7f7bec3244af",
         "x": [
          "2008-12-05",
          "2009-04-15"
         ],
         "y": [
          1,
          1
         ]
        },
        {
         "marker": {
          "color": "white"
         },
         "name": "",
         "showlegend": false,
         "type": "scatter",
         "uid": "80b5d942-d990-4b4d-ab7b-ab20954b5e3f",
         "x": [
          "2009-02-20",
          "2009-05-30"
         ],
         "y": [
          2,
          2
         ]
        },
        {
         "hoverinfo": "none",
         "marker": {
          "color": "rgb(220, 0, 0)",
          "size": 1
         },
         "name": "Apple",
         "showlegend": true,
         "type": "scatter",
         "uid": "f3528a03-d22f-4a2f-a762-db1564348769",
         "x": [
          "2009-02-20",
          "2009-02-20"
         ],
         "y": [
          0,
          0
         ]
        },
        {
         "hoverinfo": "none",
         "marker": {
          "color": "rgb(255, 230, 41)",
          "size": 1
         },
         "name": "Banana",
         "showlegend": true,
         "type": "scatter",
         "uid": "3405b64b-361e-4731-982c-b8091f18aa5d",
         "x": [
          "2009-02-20",
          "2009-02-20"
         ],
         "y": [
          1,
          1
         ]
        },
        {
         "hoverinfo": "none",
         "marker": {
          "color": "rgb(170, 14, 200)",
          "size": 1
         },
         "name": "Grape",
         "showlegend": true,
         "type": "scatter",
         "uid": "dc219024-5148-4c24-a292-64fa8ad11a19",
         "x": [
          "2009-02-20",
          "2009-02-20"
         ],
         "y": [
          2,
          2
         ]
        }
       ],
       "layout": {
        "height": 600,
        "hovermode": "closest",
        "shapes": [
         {
          "fillcolor": "rgb(220, 0, 0)",
          "line": {
           "width": 0
          },
          "opacity": 1,
          "type": "rect",
          "x0": "2009-01-01",
          "x1": "2009-02-28",
          "xref": "x",
          "y0": -0.2,
          "y1": 0.2,
          "yref": "y"
         },
         {
          "fillcolor": "rgb(170, 14, 200)",
          "line": {
           "width": 0
          },
          "opacity": 1,
          "type": "rect",
          "x0": "2008-12-05",
          "x1": "2009-04-15",
          "xref": "x",
          "y0": 0.8,
          "y1": 1.2,
          "yref": "y"
         },
         {
          "fillcolor": "rgb(255, 230, 41)",
          "line": {
           "width": 0
          },
          "opacity": 1,
          "type": "rect",
          "x0": "2009-02-20",
          "x1": "2009-05-30",
          "xref": "x",
          "y0": 1.8,
          "y1": 2.2,
          "yref": "y"
         }
        ],
        "showlegend": true,
        "title": "Gantt Chart",
        "width": 900,
        "xaxis": {
         "rangeselector": {
          "buttons": [
           {
            "count": 7,
            "label": "1w",
            "step": "day",
            "stepmode": "backward"
           },
           {
            "count": 1,
            "label": "1m",
            "step": "month",
            "stepmode": "backward"
           },
           {
            "count": 6,
            "label": "6m",
            "step": "month",
            "stepmode": "backward"
           },
           {
            "count": 1,
            "label": "YTD",
            "step": "year",
            "stepmode": "todate"
           },
           {
            "count": 1,
            "label": "1y",
            "step": "year",
            "stepmode": "backward"
           },
           {
            "step": "all"
           }
          ]
         },
         "showgrid": false,
         "type": "date",
         "zeroline": false
        },
        "yaxis": {
         "autorange": false,
         "range": [
          -1,
          4
         ],
         "showgrid": false,
         "ticktext": [
          "Job A",
          "Job B",
          "Job C"
         ],
         "tickvals": [
          0,
          1,
          2
         ],
         "zeroline": false
        }
       }
      },
      "text/html": [
       "<div id=\"8ba9242d-d665-456c-89d9-6255e79e204c\" style=\"height: 600px; width: 900px;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"8ba9242d-d665-456c-89d9-6255e79e204c\", [{\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2009-01-01\", \"2009-02-28\"], \"y\": [0, 0], \"type\": \"scatter\", \"uid\": \"34d9017d-8f03-40f8-bc31-04ce0d7d37d4\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2008-12-05\", \"2009-04-15\"], \"y\": [1, 1], \"type\": \"scatter\", \"uid\": \"4d8c2662-3fa0-482c-b085-e2c0d4429d20\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2009-02-20\", \"2009-05-30\"], \"y\": [2, 2], \"type\": \"scatter\", \"uid\": \"ec8e318e-6752-4f60-9494-bb7c65c81a47\"}, {\"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(220, 0, 0)\", \"size\": 1}, \"name\": \"Apple\", \"showlegend\": true, \"x\": [\"2009-02-20\", \"2009-02-20\"], \"y\": [0, 0], \"type\": \"scatter\", \"uid\": \"9f4513e0-43f6-4e4a-9ae7-acb038f257c5\"}, {\"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(255, 230, 41)\", \"size\": 1}, \"name\": \"Banana\", \"showlegend\": true, \"x\": [\"2009-02-20\", \"2009-02-20\"], \"y\": [1, 1], \"type\": \"scatter\", \"uid\": \"266c812c-003d-4020-a468-1fad9880a01a\"}, {\"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(170, 14, 200)\", \"size\": 1}, \"name\": \"Grape\", \"showlegend\": true, \"x\": [\"2009-02-20\", \"2009-02-20\"], \"y\": [2, 2], \"type\": \"scatter\", \"uid\": \"88030373-eb70-4f43-addb-9b091f781685\"}], {\"height\": 600, \"hovermode\": \"closest\", \"shapes\": [{\"fillcolor\": \"rgb(220, 0, 0)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2009-01-01\", \"x1\": \"2009-02-28\", \"xref\": \"x\", \"y0\": -0.2, \"y1\": 0.2, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(170, 14, 200)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2008-12-05\", \"x1\": \"2009-04-15\", \"xref\": \"x\", \"y0\": 0.8, \"y1\": 1.2, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(255, 230, 41)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2009-02-20\", \"x1\": \"2009-05-30\", \"xref\": \"x\", \"y0\": 1.8, \"y1\": 2.2, \"yref\": \"y\"}], \"showlegend\": true, \"title\": \"Gantt Chart\", \"width\": 900, \"xaxis\": {\"rangeselector\": {\"buttons\": [{\"count\": 7, \"label\": \"1w\", \"step\": \"day\", \"stepmode\": \"backward\"}, {\"count\": 1, \"label\": \"1m\", \"step\": \"month\", \"stepmode\": \"backward\"}, {\"count\": 6, \"label\": \"6m\", \"step\": \"month\", \"stepmode\": \"backward\"}, {\"count\": 1, \"label\": \"YTD\", \"step\": \"year\", \"stepmode\": \"todate\"}, {\"count\": 1, \"label\": \"1y\", \"step\": \"year\", \"stepmode\": \"backward\"}, {\"step\": \"all\"}]}, \"showgrid\": false, \"type\": \"date\", \"zeroline\": false}, \"yaxis\": {\"autorange\": false, \"range\": [-1, 4], \"showgrid\": false, \"ticktext\": [\"Job A\", \"Job B\", \"Job C\"], \"tickvals\": [0, 1, 2], \"zeroline\": false}}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script>"
      ],
      "text/vnd.plotly.v1+html": [
       "<div id=\"8ba9242d-d665-456c-89d9-6255e79e204c\" style=\"height: 600px; width: 900px;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"8ba9242d-d665-456c-89d9-6255e79e204c\", [{\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2009-01-01\", \"2009-02-28\"], \"y\": [0, 0], \"type\": \"scatter\", \"uid\": \"34d9017d-8f03-40f8-bc31-04ce0d7d37d4\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2008-12-05\", \"2009-04-15\"], \"y\": [1, 1], \"type\": \"scatter\", \"uid\": \"4d8c2662-3fa0-482c-b085-e2c0d4429d20\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2009-02-20\", \"2009-05-30\"], \"y\": [2, 2], \"type\": \"scatter\", \"uid\": \"ec8e318e-6752-4f60-9494-bb7c65c81a47\"}, {\"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(220, 0, 0)\", \"size\": 1}, \"name\": \"Apple\", \"showlegend\": true, \"x\": [\"2009-02-20\", \"2009-02-20\"], \"y\": [0, 0], \"type\": \"scatter\", \"uid\": \"9f4513e0-43f6-4e4a-9ae7-acb038f257c5\"}, {\"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(255, 230, 41)\", \"size\": 1}, \"name\": \"Banana\", \"showlegend\": true, \"x\": [\"2009-02-20\", \"2009-02-20\"], \"y\": [1, 1], \"type\": \"scatter\", \"uid\": \"266c812c-003d-4020-a468-1fad9880a01a\"}, {\"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(170, 14, 200)\", \"size\": 1}, \"name\": \"Grape\", \"showlegend\": true, \"x\": [\"2009-02-20\", \"2009-02-20\"], \"y\": [2, 2], \"type\": \"scatter\", \"uid\": \"88030373-eb70-4f43-addb-9b091f781685\"}], {\"height\": 600, \"hovermode\": \"closest\", \"shapes\": [{\"fillcolor\": \"rgb(220, 0, 0)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2009-01-01\", \"x1\": \"2009-02-28\", \"xref\": \"x\", \"y0\": -0.2, \"y1\": 0.2, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(170, 14, 200)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2008-12-05\", \"x1\": \"2009-04-15\", \"xref\": \"x\", \"y0\": 0.8, \"y1\": 1.2, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(255, 230, 41)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2009-02-20\", \"x1\": \"2009-05-30\", \"xref\": \"x\", \"y0\": 1.8, \"y1\": 2.2, \"yref\": \"y\"}], \"showlegend\": true, \"title\": \"Gantt Chart\", \"width\": 900, \"xaxis\": {\"rangeselector\": {\"buttons\": [{\"count\": 7, \"label\": \"1w\", \"step\": \"day\", \"stepmode\": \"backward\"}, {\"count\": 1, \"label\": \"1m\", \"step\": \"month\", \"stepmode\": \"backward\"}, {\"count\": 6, \"label\": \"6m\", \"step\": \"month\", \"stepmode\": \"backward\"}, {\"count\": 1, \"label\": \"YTD\", \"step\": \"year\", \"stepmode\": \"todate\"}, {\"count\": 1, \"label\": \"1y\", \"step\": \"year\", \"stepmode\": \"backward\"}, {\"step\": \"all\"}]}, \"showgrid\": false, \"type\": \"date\", \"zeroline\": false}, \"yaxis\": {\"autorange\": false, \"range\": [-1, 4], \"showgrid\": false, \"ticktext\": [\"Job A\", \"Job B\", \"Job C\"], \"tickvals\": [0, 1, 2], \"zeroline\": false}}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "df = [dict(Task=\"Job A\", Start='2009-01-01', Finish='2009-02-28', Complete=10, Resource='Apple'),\n",
    "      dict(Task=\"Job B\", Start='2008-12-05', Finish='2009-04-15', Complete=60, Resource='Grape'),\n",
    "      dict(Task=\"Job C\", Start='2009-02-20', Finish='2009-05-30', Complete=95, Resource='Banana')]\n",
    "\n",
    "# Index by Numeric Variable\n",
    "# fig = ff.create_gantt(df, colors='Viridis', index_col='Complete', show_colorbar=True)\n",
    "\n",
    "# Index by String Variable\n",
    "# colors = ['#7a0504', (0.2, 0.7, 0.3), 'rgb(210, 60, 180)']\n",
    "# fig = ff.create_gantt(df, colors=colors, index_col='Resource', reverse_colors=True, show_colorbar=True)\n",
    "\n",
    "# Use a Dictionary for Colors\n",
    "colors = dict(\n",
    "    Apple = 'rgb(220, 0, 0)',\n",
    "    Grape = 'rgb(170, 14, 200)',\n",
    "    Banana = (1, 0.9, 0.16)\n",
    ")\n",
    "fig = ff.create_gantt(df, colors=colors, index_col='Resource', show_colorbar=True)\n",
    "\n",
    "# 画图\n",
    "plotly.offline.iplot(fig, filename='gantt-variable')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Using Hours and Minutes in Times"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.plotly.v1+json": {
       "config": {
        "linkText": "Export to plot.ly",
        "plotlyServerURL": "https://plot.ly",
        "showLink": true
       },
       "data": [
        {
         "marker": {
          "color": "white"
         },
         "name": "",
         "showlegend": false,
         "type": "scatter",
         "uid": "bbc815b5-3e3d-4bb0-adda-a9441727bdf2",
         "x": [
          "2016-01-01",
          "2016-01-01 6:00:00"
         ],
         "y": [
          0,
          0
         ]
        },
        {
         "marker": {
          "color": "white"
         },
         "name": "",
         "showlegend": false,
         "type": "scatter",
         "uid": "448d2075-b037-4a77-ae3a-2907d03dc3c5",
         "x": [
          "2016-01-01 7:00:00",
          "2016-01-01 7:30:00"
         ],
         "y": [
          1,
          1
         ]
        },
        {
         "marker": {
          "color": "white"
         },
         "name": "",
         "showlegend": false,
         "type": "scatter",
         "uid": "ca2c6b6a-d6f1-4d8b-8da9-91e1d965384f",
         "x": [
          "2016-01-01 9:00:00",
          "2016-01-01 11:25:00"
         ],
         "y": [
          2,
          2
         ]
        },
        {
         "marker": {
          "color": "white"
         },
         "name": "",
         "showlegend": false,
         "type": "scatter",
         "uid": "f42e2bd5-3c8f-4f2b-97f7-6465f3c72bfd",
         "x": [
          "2016-01-01 11:30:00",
          "2016-01-01 12:00:00"
         ],
         "y": [
          3,
          3
         ]
        },
        {
         "marker": {
          "color": "white"
         },
         "name": "",
         "showlegend": false,
         "type": "scatter",
         "uid": "8155d8b0-f5e9-44cb-8213-42375ec67cbe",
         "x": [
          "2016-01-01 12:00:00",
          "2016-01-01 13:00:00"
         ],
         "y": [
          4,
          4
         ]
        },
        {
         "marker": {
          "color": "white"
         },
         "name": "",
         "showlegend": false,
         "type": "scatter",
         "uid": "beebc9c7-1e25-457e-8de5-fb5a14fe9d2e",
         "x": [
          "2016-01-01 13:00:00",
          "2016-01-01 17:00:00"
         ],
         "y": [
          5,
          5
         ]
        },
        {
         "marker": {
          "color": "white"
         },
         "name": "",
         "showlegend": false,
         "type": "scatter",
         "uid": "8ce23ec7-2409-4aac-89aa-ebab88500e73",
         "x": [
          "2016-01-01 17:30:00",
          "2016-01-01 18:30:00"
         ],
         "y": [
          6,
          6
         ]
        },
        {
         "marker": {
          "color": "white"
         },
         "name": "",
         "showlegend": false,
         "type": "scatter",
         "uid": "bca98ccd-c80c-422a-a63b-64374eba4578",
         "x": [
          "2016-01-01 18:30:00",
          "2016-01-01 19:00:00"
         ],
         "y": [
          7,
          7
         ]
        },
        {
         "marker": {
          "color": "white"
         },
         "name": "",
         "showlegend": false,
         "type": "scatter",
         "uid": "55f64f89-1e62-43a9-9bfa-2a417cd65c1b",
         "x": [
          "2016-01-01 19:00:00",
          "2016-01-01 20:00:00"
         ],
         "y": [
          8,
          8
         ]
        },
        {
         "marker": {
          "color": "white"
         },
         "name": "",
         "showlegend": false,
         "type": "scatter",
         "uid": "77d250b1-3442-4fe2-a750-1a24b425a11e",
         "x": [
          "2016-01-01 21:00:00",
          "2016-01-01 23:59:00"
         ],
         "y": [
          9,
          9
         ]
        },
        {
         "hoverinfo": "none",
         "marker": {
          "color": "rgb(58, 149, 136)",
          "size": 1
         },
         "name": "Brain",
         "showlegend": true,
         "type": "scatter",
         "uid": "a06b1160-239f-42b7-bb8a-75fc0578f40c",
         "x": [
          "2016-01-01 21:00:00",
          "2016-01-01 21:00:00"
         ],
         "y": [
          0,
          0
         ]
        },
        {
         "hoverinfo": "none",
         "marker": {
          "color": "rgb(46, 137, 205)",
          "size": 1
         },
         "name": "Cardio",
         "showlegend": true,
         "type": "scatter",
         "uid": "94efeaad-e9b5-4c91-804f-35f7737ada73",
         "x": [
          "2016-01-01 21:00:00",
          "2016-01-01 21:00:00"
         ],
         "y": [
          1,
          1
         ]
        },
        {
         "hoverinfo": "none",
         "marker": {
          "color": "rgb(114, 44, 121)",
          "size": 1
         },
         "name": "Food",
         "showlegend": true,
         "type": "scatter",
         "uid": "457733ec-dc57-4e36-a949-fee539ee7335",
         "x": [
          "2016-01-01 21:00:00",
          "2016-01-01 21:00:00"
         ],
         "y": [
          2,
          2
         ]
        },
        {
         "hoverinfo": "none",
         "marker": {
          "color": "rgb(107, 127, 135)",
          "size": 1
         },
         "name": "Rest",
         "showlegend": true,
         "type": "scatter",
         "uid": "04df199f-59f6-4f48-b673-678c7abd3727",
         "x": [
          "2016-01-01 21:00:00",
          "2016-01-01 21:00:00"
         ],
         "y": [
          3,
          3
         ]
        },
        {
         "hoverinfo": "none",
         "marker": {
          "color": "rgb(198, 47, 105)",
          "size": 1
         },
         "name": "Sleep",
         "showlegend": true,
         "type": "scatter",
         "uid": "9acf0e1c-768c-4ec9-acfd-8f52649136ec",
         "x": [
          "2016-01-01 21:00:00",
          "2016-01-01 21:00:00"
         ],
         "y": [
          4,
          4
         ]
        }
       ],
       "layout": {
        "height": 600,
        "hovermode": "closest",
        "shapes": [
         {
          "fillcolor": "rgb(198, 47, 105)",
          "line": {
           "width": 0
          },
          "opacity": 1,
          "type": "rect",
          "x0": "2016-01-01",
          "x1": "2016-01-01 6:00:00",
          "xref": "x",
          "y0": -0.8,
          "y1": 0.8,
          "yref": "y"
         },
         {
          "fillcolor": "rgb(114, 44, 121)",
          "line": {
           "width": 0
          },
          "opacity": 1,
          "type": "rect",
          "x0": "2016-01-01 7:00:00",
          "x1": "2016-01-01 7:30:00",
          "xref": "x",
          "y0": 0.19999999999999996,
          "y1": 1.8,
          "yref": "y"
         },
         {
          "fillcolor": "rgb(58, 149, 136)",
          "line": {
           "width": 0
          },
          "opacity": 1,
          "type": "rect",
          "x0": "2016-01-01 9:00:00",
          "x1": "2016-01-01 11:25:00",
          "xref": "x",
          "y0": 1.2,
          "y1": 2.8,
          "yref": "y"
         },
         {
          "fillcolor": "rgb(107, 127, 135)",
          "line": {
           "width": 0
          },
          "opacity": 1,
          "type": "rect",
          "x0": "2016-01-01 11:30:00",
          "x1": "2016-01-01 12:00:00",
          "xref": "x",
          "y0": 2.2,
          "y1": 3.8,
          "yref": "y"
         },
         {
          "fillcolor": "rgb(114, 44, 121)",
          "line": {
           "width": 0
          },
          "opacity": 1,
          "type": "rect",
          "x0": "2016-01-01 12:00:00",
          "x1": "2016-01-01 13:00:00",
          "xref": "x",
          "y0": 3.2,
          "y1": 4.8,
          "yref": "y"
         },
         {
          "fillcolor": "rgb(58, 149, 136)",
          "line": {
           "width": 0
          },
          "opacity": 1,
          "type": "rect",
          "x0": "2016-01-01 13:00:00",
          "x1": "2016-01-01 17:00:00",
          "xref": "x",
          "y0": 4.2,
          "y1": 5.8,
          "yref": "y"
         },
         {
          "fillcolor": "rgb(46, 137, 205)",
          "line": {
           "width": 0
          },
          "opacity": 1,
          "type": "rect",
          "x0": "2016-01-01 17:30:00",
          "x1": "2016-01-01 18:30:00",
          "xref": "x",
          "y0": 5.2,
          "y1": 6.8,
          "yref": "y"
         },
         {
          "fillcolor": "rgb(107, 127, 135)",
          "line": {
           "width": 0
          },
          "opacity": 1,
          "type": "rect",
          "x0": "2016-01-01 18:30:00",
          "x1": "2016-01-01 19:00:00",
          "xref": "x",
          "y0": 6.2,
          "y1": 7.8,
          "yref": "y"
         },
         {
          "fillcolor": "rgb(114, 44, 121)",
          "line": {
           "width": 0
          },
          "opacity": 1,
          "type": "rect",
          "x0": "2016-01-01 19:00:00",
          "x1": "2016-01-01 20:00:00",
          "xref": "x",
          "y0": 7.2,
          "y1": 8.8,
          "yref": "y"
         },
         {
          "fillcolor": "rgb(198, 47, 105)",
          "line": {
           "width": 0
          },
          "opacity": 1,
          "type": "rect",
          "x0": "2016-01-01 21:00:00",
          "x1": "2016-01-01 23:59:00",
          "xref": "x",
          "y0": 8.2,
          "y1": 9.8,
          "yref": "y"
         }
        ],
        "showlegend": true,
        "title": "Daily Schedule",
        "width": 900,
        "xaxis": {
         "rangeselector": {
          "buttons": [
           {
            "count": 7,
            "label": "1w",
            "step": "day",
            "stepmode": "backward"
           },
           {
            "count": 1,
            "label": "1m",
            "step": "month",
            "stepmode": "backward"
           },
           {
            "count": 6,
            "label": "6m",
            "step": "month",
            "stepmode": "backward"
           },
           {
            "count": 1,
            "label": "YTD",
            "step": "year",
            "stepmode": "todate"
           },
           {
            "count": 1,
            "label": "1y",
            "step": "year",
            "stepmode": "backward"
           },
           {
            "step": "all"
           }
          ]
         },
         "showgrid": true,
         "type": "date",
         "zeroline": false
        },
        "yaxis": {
         "autorange": false,
         "range": [
          -1,
          11
         ],
         "showgrid": true,
         "ticktext": [
          "Morning Sleep",
          "Breakfast",
          "Work",
          "Break",
          "Lunch",
          "Work",
          "Exercise",
          "Post Workout Rest",
          "Dinner",
          "Evening Sleep"
         ],
         "tickvals": [
          0,
          1,
          2,
          3,
          4,
          5,
          6,
          7,
          8,
          9
         ],
         "zeroline": false
        }
       }
      },
      "text/html": [
       "<div id=\"f8a1a83e-8bc8-4295-97bf-40a085e9cf64\" style=\"height: 600px; width: 900px;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"f8a1a83e-8bc8-4295-97bf-40a085e9cf64\", [{\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2016-01-01\", \"2016-01-01 6:00:00\"], \"y\": [0, 0], \"type\": \"scatter\", \"uid\": \"46d85982-7744-4868-8e12-60869e5b0f4a\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2016-01-01 7:00:00\", \"2016-01-01 7:30:00\"], \"y\": [1, 1], \"type\": \"scatter\", \"uid\": \"cce7f7fd-c147-4c54-ba64-a4a64e273e16\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2016-01-01 9:00:00\", \"2016-01-01 11:25:00\"], \"y\": [2, 2], \"type\": \"scatter\", \"uid\": \"192316a5-126a-4849-98dc-733bc9cb7549\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2016-01-01 11:30:00\", \"2016-01-01 12:00:00\"], \"y\": [3, 3], \"type\": \"scatter\", \"uid\": \"b128d748-0ebb-4d17-9a36-5cd6cfcdd6ac\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2016-01-01 12:00:00\", \"2016-01-01 13:00:00\"], \"y\": [4, 4], \"type\": \"scatter\", \"uid\": \"a00f3692-478b-4679-8225-c4ab135dd4b7\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2016-01-01 13:00:00\", \"2016-01-01 17:00:00\"], \"y\": [5, 5], \"type\": \"scatter\", \"uid\": \"bb12a68b-3784-4a6c-949e-211fb94e84a9\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2016-01-01 17:30:00\", \"2016-01-01 18:30:00\"], \"y\": [6, 6], \"type\": \"scatter\", \"uid\": \"f1ddd45b-a19d-450b-84d0-0db7f4d78151\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2016-01-01 18:30:00\", \"2016-01-01 19:00:00\"], \"y\": [7, 7], \"type\": \"scatter\", \"uid\": \"45978eaf-a1f2-4568-af27-8279afde8817\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2016-01-01 19:00:00\", \"2016-01-01 20:00:00\"], \"y\": [8, 8], \"type\": \"scatter\", \"uid\": \"8d43c6ee-700b-4561-8a77-566b6021627a\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2016-01-01 21:00:00\", \"2016-01-01 23:59:00\"], \"y\": [9, 9], \"type\": \"scatter\", \"uid\": \"537b5df4-94a4-490f-b677-c408169302ea\"}, {\"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(58, 149, 136)\", \"size\": 1}, \"name\": \"Brain\", \"showlegend\": true, \"x\": [\"2016-01-01 21:00:00\", \"2016-01-01 21:00:00\"], \"y\": [0, 0], \"type\": \"scatter\", \"uid\": \"6f4f152c-6633-417e-bb01-f82cbcd90470\"}, {\"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(46, 137, 205)\", \"size\": 1}, \"name\": \"Cardio\", \"showlegend\": true, \"x\": [\"2016-01-01 21:00:00\", \"2016-01-01 21:00:00\"], \"y\": [1, 1], \"type\": \"scatter\", \"uid\": \"3c6d58d7-74d4-4da5-937a-872d162da878\"}, {\"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(114, 44, 121)\", \"size\": 1}, \"name\": \"Food\", \"showlegend\": true, \"x\": [\"2016-01-01 21:00:00\", \"2016-01-01 21:00:00\"], \"y\": [2, 2], \"type\": \"scatter\", \"uid\": \"8f93b4e6-fe04-48d0-9225-0a351228f9b5\"}, {\"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(107, 127, 135)\", \"size\": 1}, \"name\": \"Rest\", \"showlegend\": true, \"x\": [\"2016-01-01 21:00:00\", \"2016-01-01 21:00:00\"], \"y\": [3, 3], \"type\": \"scatter\", \"uid\": \"3452a180-12ab-4ef1-abc0-680342bcf0f5\"}, {\"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(198, 47, 105)\", \"size\": 1}, \"name\": \"Sleep\", \"showlegend\": true, \"x\": [\"2016-01-01 21:00:00\", \"2016-01-01 21:00:00\"], \"y\": [4, 4], \"type\": \"scatter\", \"uid\": \"4563f19f-d87c-4c6f-adc7-40351d684f9f\"}], {\"height\": 600, \"hovermode\": \"closest\", \"shapes\": [{\"fillcolor\": \"rgb(198, 47, 105)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2016-01-01\", \"x1\": \"2016-01-01 6:00:00\", \"xref\": \"x\", \"y0\": -0.8, \"y1\": 0.8, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(114, 44, 121)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2016-01-01 7:00:00\", \"x1\": \"2016-01-01 7:30:00\", \"xref\": \"x\", \"y0\": 0.19999999999999996, \"y1\": 1.8, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(58, 149, 136)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2016-01-01 9:00:00\", \"x1\": \"2016-01-01 11:25:00\", \"xref\": \"x\", \"y0\": 1.2, \"y1\": 2.8, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(107, 127, 135)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2016-01-01 11:30:00\", \"x1\": \"2016-01-01 12:00:00\", \"xref\": \"x\", \"y0\": 2.2, \"y1\": 3.8, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(114, 44, 121)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2016-01-01 12:00:00\", \"x1\": \"2016-01-01 13:00:00\", \"xref\": \"x\", \"y0\": 3.2, \"y1\": 4.8, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(58, 149, 136)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2016-01-01 13:00:00\", \"x1\": \"2016-01-01 17:00:00\", \"xref\": \"x\", \"y0\": 4.2, \"y1\": 5.8, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(46, 137, 205)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2016-01-01 17:30:00\", \"x1\": \"2016-01-01 18:30:00\", \"xref\": \"x\", \"y0\": 5.2, \"y1\": 6.8, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(107, 127, 135)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2016-01-01 18:30:00\", \"x1\": \"2016-01-01 19:00:00\", \"xref\": \"x\", \"y0\": 6.2, \"y1\": 7.8, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(114, 44, 121)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2016-01-01 19:00:00\", \"x1\": \"2016-01-01 20:00:00\", \"xref\": \"x\", \"y0\": 7.2, \"y1\": 8.8, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(198, 47, 105)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2016-01-01 21:00:00\", \"x1\": \"2016-01-01 23:59:00\", \"xref\": \"x\", \"y0\": 8.2, \"y1\": 9.8, \"yref\": \"y\"}], \"showlegend\": true, \"title\": \"Daily Schedule\", \"width\": 900, \"xaxis\": {\"rangeselector\": {\"buttons\": [{\"count\": 7, \"label\": \"1w\", \"step\": \"day\", \"stepmode\": \"backward\"}, {\"count\": 1, \"label\": \"1m\", \"step\": \"month\", \"stepmode\": \"backward\"}, {\"count\": 6, \"label\": \"6m\", \"step\": \"month\", \"stepmode\": \"backward\"}, {\"count\": 1, \"label\": \"YTD\", \"step\": \"year\", \"stepmode\": \"todate\"}, {\"count\": 1, \"label\": \"1y\", \"step\": \"year\", \"stepmode\": \"backward\"}, {\"step\": \"all\"}]}, \"showgrid\": true, \"type\": \"date\", \"zeroline\": false}, \"yaxis\": {\"autorange\": false, \"range\": [-1, 11], \"showgrid\": true, \"ticktext\": [\"Morning Sleep\", \"Breakfast\", \"Work\", \"Break\", \"Lunch\", \"Work\", \"Exercise\", \"Post Workout Rest\", \"Dinner\", \"Evening Sleep\"], \"tickvals\": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], \"zeroline\": false}}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script>"
      ],
      "text/vnd.plotly.v1+html": [
       "<div id=\"f8a1a83e-8bc8-4295-97bf-40a085e9cf64\" style=\"height: 600px; width: 900px;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"f8a1a83e-8bc8-4295-97bf-40a085e9cf64\", [{\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2016-01-01\", \"2016-01-01 6:00:00\"], \"y\": [0, 0], \"type\": \"scatter\", \"uid\": \"46d85982-7744-4868-8e12-60869e5b0f4a\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2016-01-01 7:00:00\", \"2016-01-01 7:30:00\"], \"y\": [1, 1], \"type\": \"scatter\", \"uid\": \"cce7f7fd-c147-4c54-ba64-a4a64e273e16\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2016-01-01 9:00:00\", \"2016-01-01 11:25:00\"], \"y\": [2, 2], \"type\": \"scatter\", \"uid\": \"192316a5-126a-4849-98dc-733bc9cb7549\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2016-01-01 11:30:00\", \"2016-01-01 12:00:00\"], \"y\": [3, 3], \"type\": \"scatter\", \"uid\": \"b128d748-0ebb-4d17-9a36-5cd6cfcdd6ac\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2016-01-01 12:00:00\", \"2016-01-01 13:00:00\"], \"y\": [4, 4], \"type\": \"scatter\", \"uid\": \"a00f3692-478b-4679-8225-c4ab135dd4b7\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2016-01-01 13:00:00\", \"2016-01-01 17:00:00\"], \"y\": [5, 5], \"type\": \"scatter\", \"uid\": \"bb12a68b-3784-4a6c-949e-211fb94e84a9\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2016-01-01 17:30:00\", \"2016-01-01 18:30:00\"], \"y\": [6, 6], \"type\": \"scatter\", \"uid\": \"f1ddd45b-a19d-450b-84d0-0db7f4d78151\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2016-01-01 18:30:00\", \"2016-01-01 19:00:00\"], \"y\": [7, 7], \"type\": \"scatter\", \"uid\": \"45978eaf-a1f2-4568-af27-8279afde8817\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2016-01-01 19:00:00\", \"2016-01-01 20:00:00\"], \"y\": [8, 8], \"type\": \"scatter\", \"uid\": \"8d43c6ee-700b-4561-8a77-566b6021627a\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2016-01-01 21:00:00\", \"2016-01-01 23:59:00\"], \"y\": [9, 9], \"type\": \"scatter\", \"uid\": \"537b5df4-94a4-490f-b677-c408169302ea\"}, {\"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(58, 149, 136)\", \"size\": 1}, \"name\": \"Brain\", \"showlegend\": true, \"x\": [\"2016-01-01 21:00:00\", \"2016-01-01 21:00:00\"], \"y\": [0, 0], \"type\": \"scatter\", \"uid\": \"6f4f152c-6633-417e-bb01-f82cbcd90470\"}, {\"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(46, 137, 205)\", \"size\": 1}, \"name\": \"Cardio\", \"showlegend\": true, \"x\": [\"2016-01-01 21:00:00\", \"2016-01-01 21:00:00\"], \"y\": [1, 1], \"type\": \"scatter\", \"uid\": \"3c6d58d7-74d4-4da5-937a-872d162da878\"}, {\"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(114, 44, 121)\", \"size\": 1}, \"name\": \"Food\", \"showlegend\": true, \"x\": [\"2016-01-01 21:00:00\", \"2016-01-01 21:00:00\"], \"y\": [2, 2], \"type\": \"scatter\", \"uid\": \"8f93b4e6-fe04-48d0-9225-0a351228f9b5\"}, {\"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(107, 127, 135)\", \"size\": 1}, \"name\": \"Rest\", \"showlegend\": true, \"x\": [\"2016-01-01 21:00:00\", \"2016-01-01 21:00:00\"], \"y\": [3, 3], \"type\": \"scatter\", \"uid\": \"3452a180-12ab-4ef1-abc0-680342bcf0f5\"}, {\"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(198, 47, 105)\", \"size\": 1}, \"name\": \"Sleep\", \"showlegend\": true, \"x\": [\"2016-01-01 21:00:00\", \"2016-01-01 21:00:00\"], \"y\": [4, 4], \"type\": \"scatter\", \"uid\": \"4563f19f-d87c-4c6f-adc7-40351d684f9f\"}], {\"height\": 600, \"hovermode\": \"closest\", \"shapes\": [{\"fillcolor\": \"rgb(198, 47, 105)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2016-01-01\", \"x1\": \"2016-01-01 6:00:00\", \"xref\": \"x\", \"y0\": -0.8, \"y1\": 0.8, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(114, 44, 121)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2016-01-01 7:00:00\", \"x1\": \"2016-01-01 7:30:00\", \"xref\": \"x\", \"y0\": 0.19999999999999996, \"y1\": 1.8, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(58, 149, 136)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2016-01-01 9:00:00\", \"x1\": \"2016-01-01 11:25:00\", \"xref\": \"x\", \"y0\": 1.2, \"y1\": 2.8, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(107, 127, 135)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2016-01-01 11:30:00\", \"x1\": \"2016-01-01 12:00:00\", \"xref\": \"x\", \"y0\": 2.2, \"y1\": 3.8, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(114, 44, 121)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2016-01-01 12:00:00\", \"x1\": \"2016-01-01 13:00:00\", \"xref\": \"x\", \"y0\": 3.2, \"y1\": 4.8, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(58, 149, 136)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2016-01-01 13:00:00\", \"x1\": \"2016-01-01 17:00:00\", \"xref\": \"x\", \"y0\": 4.2, \"y1\": 5.8, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(46, 137, 205)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2016-01-01 17:30:00\", \"x1\": \"2016-01-01 18:30:00\", \"xref\": \"x\", \"y0\": 5.2, \"y1\": 6.8, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(107, 127, 135)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2016-01-01 18:30:00\", \"x1\": \"2016-01-01 19:00:00\", \"xref\": \"x\", \"y0\": 6.2, \"y1\": 7.8, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(114, 44, 121)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2016-01-01 19:00:00\", \"x1\": \"2016-01-01 20:00:00\", \"xref\": \"x\", \"y0\": 7.2, \"y1\": 8.8, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(198, 47, 105)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2016-01-01 21:00:00\", \"x1\": \"2016-01-01 23:59:00\", \"xref\": \"x\", \"y0\": 8.2, \"y1\": 9.8, \"yref\": \"y\"}], \"showlegend\": true, \"title\": \"Daily Schedule\", \"width\": 900, \"xaxis\": {\"rangeselector\": {\"buttons\": [{\"count\": 7, \"label\": \"1w\", \"step\": \"day\", \"stepmode\": \"backward\"}, {\"count\": 1, \"label\": \"1m\", \"step\": \"month\", \"stepmode\": \"backward\"}, {\"count\": 6, \"label\": \"6m\", \"step\": \"month\", \"stepmode\": \"backward\"}, {\"count\": 1, \"label\": \"YTD\", \"step\": \"year\", \"stepmode\": \"todate\"}, {\"count\": 1, \"label\": \"1y\", \"step\": \"year\", \"stepmode\": \"backward\"}, {\"step\": \"all\"}]}, \"showgrid\": true, \"type\": \"date\", \"zeroline\": false}, \"yaxis\": {\"autorange\": false, \"range\": [-1, 11], \"showgrid\": true, \"ticktext\": [\"Morning Sleep\", \"Breakfast\", \"Work\", \"Break\", \"Lunch\", \"Work\", \"Exercise\", \"Post Workout Rest\", \"Dinner\", \"Evening Sleep\"], \"tickvals\": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], \"zeroline\": false}}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "df = [\n",
    "    dict(Task='Morning Sleep', Start='2016-01-01', Finish='2016-01-01 6:00:00', Resource='Sleep'),\n",
    "    dict(Task='Breakfast', Start='2016-01-01 7:00:00', Finish='2016-01-01 7:30:00', Resource='Food'),\n",
    "    dict(Task='Work', Start='2016-01-01 9:00:00', Finish='2016-01-01 11:25:00', Resource='Brain'),\n",
    "    dict(Task='Break', Start='2016-01-01 11:30:00', Finish='2016-01-01 12:00:00', Resource='Rest'),\n",
    "    dict(Task='Lunch', Start='2016-01-01 12:00:00', Finish='2016-01-01 13:00:00', Resource='Food'),\n",
    "    dict(Task='Work', Start='2016-01-01 13:00:00', Finish='2016-01-01 17:00:00', Resource='Brain'),\n",
    "    dict(Task='Exercise', Start='2016-01-01 17:30:00', Finish='2016-01-01 18:30:00', Resource='Cardio'), \n",
    "    dict(Task='Post Workout Rest', Start='2016-01-01 18:30:00', Finish='2016-01-01 19:00:00', Resource='Rest'),\n",
    "    dict(Task='Dinner', Start='2016-01-01 19:00:00', Finish='2016-01-01 20:00:00', Resource='Food'),\n",
    "    dict(Task='Evening Sleep', Start='2016-01-01 21:00:00', Finish='2016-01-01 23:59:00', Resource='Sleep')\n",
    "]\n",
    "\n",
    "colors = dict(\n",
    "    Cardio = 'rgb(46, 137, 205)', \n",
    "    Food = 'rgb(114, 44, 121)',\n",
    "    Sleep = 'rgb(198, 47, 105)',\n",
    "    Brain = 'rgb(58, 149, 136)',\n",
    "    Rest = 'rgb(107, 127, 135)'\n",
    ")\n",
    "fig = ff.create_gantt(df, colors=colors, index_col='Resource', title='Daily Schedule', show_colorbar=True, bar_width=0.8, showgrid_x=True, showgrid_y=True)\n",
    "plotly.offline.iplot(fig, filename='gantt-hours-minutes')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Group Tasks Together"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.plotly.v1+json": {
       "config": {
        "linkText": "Export to plot.ly",
        "plotlyServerURL": "https://plot.ly",
        "showLink": true
       },
       "data": [
        {
         "marker": {
          "color": "white"
         },
         "name": "",
         "showlegend": false,
         "type": "scatter",
         "uid": "150785e6-6711-4901-bb24-90c161f83296",
         "x": [
          "2017-01-01",
          "2017-02-02"
         ],
         "y": [
          3,
          3
         ]
        },
        {
         "marker": {
          "color": "white"
         },
         "name": "",
         "showlegend": false,
         "type": "scatter",
         "uid": "b67e0e32-49e5-4a4c-b8e5-81513cb7223d",
         "x": [
          "2017-02-15",
          "2017-03-15"
         ],
         "y": [
          3,
          3
         ]
        },
        {
         "marker": {
          "color": "white"
         },
         "name": "",
         "showlegend": false,
         "type": "scatter",
         "uid": "77e2204c-a733-4ab4-862c-96d4c96aa6c1",
         "x": [
          "2017-01-17",
          "2017-02-17"
         ],
         "y": [
          2,
          2
         ]
        },
        {
         "marker": {
          "color": "white"
         },
         "name": "",
         "showlegend": false,
         "type": "scatter",
         "uid": "3cf19bc3-49a3-41a5-b69c-238898504789",
         "x": [
          "2017-01-17",
          "2017-02-17"
         ],
         "y": [
          2,
          2
         ]
        },
        {
         "marker": {
          "color": "white"
         },
         "name": "",
         "showlegend": false,
         "type": "scatter",
         "uid": "c541483a-f70e-4c32-905d-b7ec797534cc",
         "x": [
          "2017-03-10",
          "2017-03-20"
         ],
         "y": [
          1,
          1
         ]
        },
        {
         "marker": {
          "color": "white"
         },
         "name": "",
         "showlegend": false,
         "type": "scatter",
         "uid": "2471ca29-b4f3-4d2c-97d6-ca2d6fe91aa5",
         "x": [
          "2017-04-01",
          "2017-04-20"
         ],
         "y": [
          1,
          1
         ]
        },
        {
         "marker": {
          "color": "white"
         },
         "name": "",
         "showlegend": false,
         "type": "scatter",
         "uid": "bddc84a7-32d8-4497-8acc-8fac7336199f",
         "x": [
          "2017-05-18",
          "2017-06-18"
         ],
         "y": [
          1,
          1
         ]
        },
        {
         "marker": {
          "color": "white"
         },
         "name": "",
         "showlegend": false,
         "type": "scatter",
         "uid": "4d1ed175-88cf-4cd9-a44d-65fae06de54e",
         "x": [
          "2017-01-14",
          "2017-03-14"
         ],
         "y": [
          0,
          0
         ]
        },
        {
         "hoverinfo": "none",
         "marker": {
          "color": "rgb(0, 255, 100)",
          "size": 1
         },
         "name": "Complete",
         "showlegend": true,
         "type": "scatter",
         "uid": "603b3204-1530-4e01-91c6-12275df475eb",
         "x": [
          "2017-01-14",
          "2017-01-14"
         ],
         "y": [
          0,
          0
         ]
        },
        {
         "hoverinfo": "none",
         "marker": {
          "color": "rgb(255, 230, 41)",
          "size": 1
         },
         "name": "Incomplete",
         "showlegend": true,
         "type": "scatter",
         "uid": "bcf5be18-b20e-4bfe-95cd-1ec6f84c1e66",
         "x": [
          "2017-01-14",
          "2017-01-14"
         ],
         "y": [
          1,
          1
         ]
        },
        {
         "hoverinfo": "none",
         "marker": {
          "color": "rgb(220, 0, 0)",
          "size": 1
         },
         "name": "Not Started",
         "showlegend": true,
         "type": "scatter",
         "uid": "ea881c4f-a36c-42bc-9c7d-a33a47b21f3d",
         "x": [
          "2017-01-14",
          "2017-01-14"
         ],
         "y": [
          2,
          2
         ]
        }
       ],
       "layout": {
        "height": 600,
        "hovermode": "closest",
        "shapes": [
         {
          "fillcolor": "rgb(0, 255, 100)",
          "line": {
           "width": 0
          },
          "opacity": 1,
          "type": "rect",
          "x0": "2017-01-01",
          "x1": "2017-02-02",
          "xref": "x",
          "y0": 2.8,
          "y1": 3.2,
          "yref": "y"
         },
         {
          "fillcolor": "rgb(255, 230, 41)",
          "line": {
           "width": 0
          },
          "opacity": 1,
          "type": "rect",
          "x0": "2017-02-15",
          "x1": "2017-03-15",
          "xref": "x",
          "y0": 2.8,
          "y1": 3.2,
          "yref": "y"
         },
         {
          "fillcolor": "rgb(220, 0, 0)",
          "line": {
           "width": 0
          },
          "opacity": 1,
          "type": "rect",
          "x0": "2017-01-17",
          "x1": "2017-02-17",
          "xref": "x",
          "y0": 1.8,
          "y1": 2.2,
          "yref": "y"
         },
         {
          "fillcolor": "rgb(0, 255, 100)",
          "line": {
           "width": 0
          },
          "opacity": 1,
          "type": "rect",
          "x0": "2017-01-17",
          "x1": "2017-02-17",
          "xref": "x",
          "y0": 1.8,
          "y1": 2.2,
          "yref": "y"
         },
         {
          "fillcolor": "rgb(220, 0, 0)",
          "line": {
           "width": 0
          },
          "opacity": 1,
          "type": "rect",
          "x0": "2017-03-10",
          "x1": "2017-03-20",
          "xref": "x",
          "y0": 0.8,
          "y1": 1.2,
          "yref": "y"
         },
         {
          "fillcolor": "rgb(220, 0, 0)",
          "line": {
           "width": 0
          },
          "opacity": 1,
          "type": "rect",
          "x0": "2017-04-01",
          "x1": "2017-04-20",
          "xref": "x",
          "y0": 0.8,
          "y1": 1.2,
          "yref": "y"
         },
         {
          "fillcolor": "rgb(220, 0, 0)",
          "line": {
           "width": 0
          },
          "opacity": 1,
          "type": "rect",
          "x0": "2017-05-18",
          "x1": "2017-06-18",
          "xref": "x",
          "y0": 0.8,
          "y1": 1.2,
          "yref": "y"
         },
         {
          "fillcolor": "rgb(0, 255, 100)",
          "line": {
           "width": 0
          },
          "opacity": 1,
          "type": "rect",
          "x0": "2017-01-14",
          "x1": "2017-03-14",
          "xref": "x",
          "y0": -0.2,
          "y1": 0.2,
          "yref": "y"
         }
        ],
        "showlegend": true,
        "title": "Gantt Chart",
        "width": 900,
        "xaxis": {
         "rangeselector": {
          "buttons": [
           {
            "count": 7,
            "label": "1w",
            "step": "day",
            "stepmode": "backward"
           },
           {
            "count": 1,
            "label": "1m",
            "step": "month",
            "stepmode": "backward"
           },
           {
            "count": 6,
            "label": "6m",
            "step": "month",
            "stepmode": "backward"
           },
           {
            "count": 1,
            "label": "YTD",
            "step": "year",
            "stepmode": "todate"
           },
           {
            "count": 1,
            "label": "1y",
            "step": "year",
            "stepmode": "backward"
           },
           {
            "step": "all"
           }
          ]
         },
         "showgrid": false,
         "type": "date",
         "zeroline": false
        },
        "yaxis": {
         "autorange": false,
         "range": [
          -1,
          5
         ],
         "showgrid": false,
         "ticktext": [
          "Job-4",
          "Job-3",
          "Job-2",
          "Job-1"
         ],
         "tickvals": [
          0,
          1,
          2,
          3
         ],
         "zeroline": false
        }
       }
      },
      "text/html": [
       "<div id=\"845c232f-debc-4b49-9bb3-d091f9c55a77\" style=\"height: 600px; width: 900px;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"845c232f-debc-4b49-9bb3-d091f9c55a77\", [{\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2017-01-01\", \"2017-02-02\"], \"y\": [3, 3], \"type\": \"scatter\", \"uid\": \"39fbd935-2556-423e-9208-d48c74c1ed3f\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2017-02-15\", \"2017-03-15\"], \"y\": [3, 3], \"type\": \"scatter\", \"uid\": \"2b6569b5-8bbb-4986-a77c-a827676de376\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2017-01-17\", \"2017-02-17\"], \"y\": [2, 2], \"type\": \"scatter\", \"uid\": \"d2f0020d-4ab9-4b8f-8d4a-8dc970edc1f8\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2017-01-17\", \"2017-02-17\"], \"y\": [2, 2], \"type\": \"scatter\", \"uid\": \"03132bce-5535-400d-a201-44f2822072df\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2017-03-10\", \"2017-03-20\"], \"y\": [1, 1], \"type\": \"scatter\", \"uid\": \"43b556ed-5052-4073-ad4b-a7a0f7a38749\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2017-04-01\", \"2017-04-20\"], \"y\": [1, 1], \"type\": \"scatter\", \"uid\": \"e83379fa-a513-4a20-af0c-d80e434a9d95\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2017-05-18\", \"2017-06-18\"], \"y\": [1, 1], \"type\": \"scatter\", \"uid\": \"60bf1803-823c-43a5-aec1-0131b114d1d2\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2017-01-14\", \"2017-03-14\"], \"y\": [0, 0], \"type\": \"scatter\", \"uid\": \"42e71205-8792-46fd-a828-a267ababecba\"}, {\"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(0, 255, 100)\", \"size\": 1}, \"name\": \"Complete\", \"showlegend\": true, \"x\": [\"2017-01-14\", \"2017-01-14\"], \"y\": [0, 0], \"type\": \"scatter\", \"uid\": \"5f5c8ad3-2efc-4d52-9692-5461edc32c0b\"}, {\"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(255, 230, 41)\", \"size\": 1}, \"name\": \"Incomplete\", \"showlegend\": true, \"x\": [\"2017-01-14\", \"2017-01-14\"], \"y\": [1, 1], \"type\": \"scatter\", \"uid\": \"41fedc8c-7d54-49f3-95b8-3442be7e78af\"}, {\"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(220, 0, 0)\", \"size\": 1}, \"name\": \"Not Started\", \"showlegend\": true, \"x\": [\"2017-01-14\", \"2017-01-14\"], \"y\": [2, 2], \"type\": \"scatter\", \"uid\": \"074c2101-ac75-4d90-becc-b38d75c048ea\"}], {\"height\": 600, \"hovermode\": \"closest\", \"shapes\": [{\"fillcolor\": \"rgb(0, 255, 100)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2017-01-01\", \"x1\": \"2017-02-02\", \"xref\": \"x\", \"y0\": 2.8, \"y1\": 3.2, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(255, 230, 41)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2017-02-15\", \"x1\": \"2017-03-15\", \"xref\": \"x\", \"y0\": 2.8, \"y1\": 3.2, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(220, 0, 0)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2017-01-17\", \"x1\": \"2017-02-17\", \"xref\": \"x\", \"y0\": 1.8, \"y1\": 2.2, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(0, 255, 100)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2017-01-17\", \"x1\": \"2017-02-17\", \"xref\": \"x\", \"y0\": 1.8, \"y1\": 2.2, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(220, 0, 0)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2017-03-10\", \"x1\": \"2017-03-20\", \"xref\": \"x\", \"y0\": 0.8, \"y1\": 1.2, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(220, 0, 0)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2017-04-01\", \"x1\": \"2017-04-20\", \"xref\": \"x\", \"y0\": 0.8, \"y1\": 1.2, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(220, 0, 0)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2017-05-18\", \"x1\": \"2017-06-18\", \"xref\": \"x\", \"y0\": 0.8, \"y1\": 1.2, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(0, 255, 100)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2017-01-14\", \"x1\": \"2017-03-14\", \"xref\": \"x\", \"y0\": -0.2, \"y1\": 0.2, \"yref\": \"y\"}], \"showlegend\": true, \"title\": \"Gantt Chart\", \"width\": 900, \"xaxis\": {\"rangeselector\": {\"buttons\": [{\"count\": 7, \"label\": \"1w\", \"step\": \"day\", \"stepmode\": \"backward\"}, {\"count\": 1, \"label\": \"1m\", \"step\": \"month\", \"stepmode\": \"backward\"}, {\"count\": 6, \"label\": \"6m\", \"step\": \"month\", \"stepmode\": \"backward\"}, {\"count\": 1, \"label\": \"YTD\", \"step\": \"year\", \"stepmode\": \"todate\"}, {\"count\": 1, \"label\": \"1y\", \"step\": \"year\", \"stepmode\": \"backward\"}, {\"step\": \"all\"}]}, \"showgrid\": false, \"type\": \"date\", \"zeroline\": false}, \"yaxis\": {\"autorange\": false, \"range\": [-1, 5], \"showgrid\": false, \"ticktext\": [\"Job-4\", \"Job-3\", \"Job-2\", \"Job-1\"], \"tickvals\": [0, 1, 2, 3], \"zeroline\": false}}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script>"
      ],
      "text/vnd.plotly.v1+html": [
       "<div id=\"845c232f-debc-4b49-9bb3-d091f9c55a77\" style=\"height: 600px; width: 900px;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";Plotly.newPlot(\"845c232f-debc-4b49-9bb3-d091f9c55a77\", [{\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2017-01-01\", \"2017-02-02\"], \"y\": [3, 3], \"type\": \"scatter\", \"uid\": \"39fbd935-2556-423e-9208-d48c74c1ed3f\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2017-02-15\", \"2017-03-15\"], \"y\": [3, 3], \"type\": \"scatter\", \"uid\": \"2b6569b5-8bbb-4986-a77c-a827676de376\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2017-01-17\", \"2017-02-17\"], \"y\": [2, 2], \"type\": \"scatter\", \"uid\": \"d2f0020d-4ab9-4b8f-8d4a-8dc970edc1f8\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2017-01-17\", \"2017-02-17\"], \"y\": [2, 2], \"type\": \"scatter\", \"uid\": \"03132bce-5535-400d-a201-44f2822072df\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2017-03-10\", \"2017-03-20\"], \"y\": [1, 1], \"type\": \"scatter\", \"uid\": \"43b556ed-5052-4073-ad4b-a7a0f7a38749\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2017-04-01\", \"2017-04-20\"], \"y\": [1, 1], \"type\": \"scatter\", \"uid\": \"e83379fa-a513-4a20-af0c-d80e434a9d95\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2017-05-18\", \"2017-06-18\"], \"y\": [1, 1], \"type\": \"scatter\", \"uid\": \"60bf1803-823c-43a5-aec1-0131b114d1d2\"}, {\"marker\": {\"color\": \"white\"}, \"name\": \"\", \"showlegend\": false, \"x\": [\"2017-01-14\", \"2017-03-14\"], \"y\": [0, 0], \"type\": \"scatter\", \"uid\": \"42e71205-8792-46fd-a828-a267ababecba\"}, {\"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(0, 255, 100)\", \"size\": 1}, \"name\": \"Complete\", \"showlegend\": true, \"x\": [\"2017-01-14\", \"2017-01-14\"], \"y\": [0, 0], \"type\": \"scatter\", \"uid\": \"5f5c8ad3-2efc-4d52-9692-5461edc32c0b\"}, {\"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(255, 230, 41)\", \"size\": 1}, \"name\": \"Incomplete\", \"showlegend\": true, \"x\": [\"2017-01-14\", \"2017-01-14\"], \"y\": [1, 1], \"type\": \"scatter\", \"uid\": \"41fedc8c-7d54-49f3-95b8-3442be7e78af\"}, {\"hoverinfo\": \"none\", \"marker\": {\"color\": \"rgb(220, 0, 0)\", \"size\": 1}, \"name\": \"Not Started\", \"showlegend\": true, \"x\": [\"2017-01-14\", \"2017-01-14\"], \"y\": [2, 2], \"type\": \"scatter\", \"uid\": \"074c2101-ac75-4d90-becc-b38d75c048ea\"}], {\"height\": 600, \"hovermode\": \"closest\", \"shapes\": [{\"fillcolor\": \"rgb(0, 255, 100)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2017-01-01\", \"x1\": \"2017-02-02\", \"xref\": \"x\", \"y0\": 2.8, \"y1\": 3.2, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(255, 230, 41)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2017-02-15\", \"x1\": \"2017-03-15\", \"xref\": \"x\", \"y0\": 2.8, \"y1\": 3.2, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(220, 0, 0)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2017-01-17\", \"x1\": \"2017-02-17\", \"xref\": \"x\", \"y0\": 1.8, \"y1\": 2.2, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(0, 255, 100)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2017-01-17\", \"x1\": \"2017-02-17\", \"xref\": \"x\", \"y0\": 1.8, \"y1\": 2.2, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(220, 0, 0)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2017-03-10\", \"x1\": \"2017-03-20\", \"xref\": \"x\", \"y0\": 0.8, \"y1\": 1.2, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(220, 0, 0)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2017-04-01\", \"x1\": \"2017-04-20\", \"xref\": \"x\", \"y0\": 0.8, \"y1\": 1.2, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(220, 0, 0)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2017-05-18\", \"x1\": \"2017-06-18\", \"xref\": \"x\", \"y0\": 0.8, \"y1\": 1.2, \"yref\": \"y\"}, {\"fillcolor\": \"rgb(0, 255, 100)\", \"line\": {\"width\": 0}, \"opacity\": 1, \"type\": \"rect\", \"x0\": \"2017-01-14\", \"x1\": \"2017-03-14\", \"xref\": \"x\", \"y0\": -0.2, \"y1\": 0.2, \"yref\": \"y\"}], \"showlegend\": true, \"title\": \"Gantt Chart\", \"width\": 900, \"xaxis\": {\"rangeselector\": {\"buttons\": [{\"count\": 7, \"label\": \"1w\", \"step\": \"day\", \"stepmode\": \"backward\"}, {\"count\": 1, \"label\": \"1m\", \"step\": \"month\", \"stepmode\": \"backward\"}, {\"count\": 6, \"label\": \"6m\", \"step\": \"month\", \"stepmode\": \"backward\"}, {\"count\": 1, \"label\": \"YTD\", \"step\": \"year\", \"stepmode\": \"todate\"}, {\"count\": 1, \"label\": \"1y\", \"step\": \"year\", \"stepmode\": \"backward\"}, {\"step\": \"all\"}]}, \"showgrid\": false, \"type\": \"date\", \"zeroline\": false}, \"yaxis\": {\"autorange\": false, \"range\": [-1, 5], \"showgrid\": false, \"ticktext\": [\"Job-4\", \"Job-3\", \"Job-2\", \"Job-1\"], \"tickvals\": [0, 1, 2, 3], \"zeroline\": false}}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"})});</script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "df = [\n",
    "    dict(Task=\"Job-1\", Start='2017-01-01', Finish='2017-02-02', Resource='Complete'),\n",
    "    dict(Task=\"Job-1\", Start='2017-02-15', Finish='2017-03-15', Resource='Incomplete'),\n",
    "    dict(Task=\"Job-2\", Start='2017-01-17', Finish='2017-02-17', Resource='Not Started'),\n",
    "    dict(Task=\"Job-2\", Start='2017-01-17', Finish='2017-02-17', Resource='Complete'),\n",
    "    dict(Task=\"Job-3\", Start='2017-03-10', Finish='2017-03-20', Resource='Not Started'),\n",
    "    dict(Task=\"Job-3\", Start='2017-04-01', Finish='2017-04-20', Resource='Not Started'),\n",
    "    dict(Task=\"Job-3\", Start='2017-05-18', Finish='2017-06-18', Resource='Not Started'),\n",
    "    dict(Task=\"Job-4\", Start='2017-01-14', Finish='2017-03-14', Resource='Complete')\n",
    "]\n",
    "\n",
    "colors = {\n",
    "    'Not Started': 'rgb(220, 0, 0)',\n",
    "    'Incomplete': (1, 0.9, 0.16),\n",
    "    'Complete': 'rgb(0, 255, 100)'\n",
    "}\n",
    "fig = ff.create_gantt(df, colors=colors, index_col='Resource', show_colorbar=True, group_tasks=True)\n",
    "plotly.offline.iplot(fig, filename='gantt-group-tasks-together')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
